package com.example.myapplication.database

import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import com.example.myapplcation.entity.PopularScienceMineEntity

/**
 * 睡眠数据库
 * */
@Database(entities = [
    PopularScienceMineEntity::class,
    ],
    version = 1,exportSchema = true,
)
abstract class DataBaseUtils: RoomDatabase(){
    companion object{
        @Volatile
        private var instance: DataBaseUtils? = null
        fun getInstance(context: Context):DataBaseUtils{
            instance ?: synchronized(this){
                instance = Room.databaseBuilder(context,DataBaseUtils::class.java,"antiquities.db")
//                    .allowMainThreadQueries() //是否允许在主线程进行查询
                    .build()
            }
            return instance!!
        }
    }

    abstract fun dataBaseDao(): DataBaseDao
}